include ../../build/config.mk
CC=g++
SQLRELAY_DIR=$(INSTALL_DIR)
SQLRELAY_LIB_DIR=$(SQLRELAY_DIR)/lib
SQLRELAY_INCLUDE_DIR=$(SQLRELAY_DIR)/include
PLUGIN_DIR=$(SQLRELAY_DIR)/libexec/sqlrelay/

SRC=lktencrypt.cpp ../shm/lktshm.cpp ../cipher/lktcipher.c sqlfield.cpp character.cpp
INCLUDE=-I../sqlparser -I$(SQLRELAY_INCLUDE_DIR) -I../../dep/openssl/include -I../cipher -I../public -I../shm -I../../dep/zlog/include
LIB=-L../sqlparser -L../../dep/sqlparser/lib/ -L$(SQLRELAY_LIB_DIR) -L../../dep/openssl/lib -L../../dep/zlog/lib
PLUGIN=sqlrtranslation_lktencrypt.so
LDFLAGS= $(LIB)  -Wl,-whole-archive -lgspcore -lgspcollection -llktsqlparser -lzlog -Wl,-no-whole-archive -lcrypto --std=c++11

all:
	$(CC) $(SRC) $(CFLAGS) -o $(PLUGIN) $(LDFLAGS) -DINSTALL_DIR=\"$(INSTALL_DIR)\" -fPIC -shared $(INCLUDE)
install:
	cp $(PLUGIN) $(PLUGIN_DIR) -fr

clean:
	rm -fr $(PLUGIN)

